﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Xml.Linq;
using BUSINESS_OBJECT;
namespace CRM.customer
{
    public partial class WebForm5 : System.Web.UI.Page
    {
        STAFFI staf = new STAFFI();

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                DataTable dt = staf.GetRecords(-99, -99, "", "", "", "", -99, -99, "",Convert.ToDateTime("1/1/1800"), "", -99, false, " and ");
                GridView1.DataSource = dt;
                GridView1.DataBind();
            }
       }

        protected void Button1_Click(object sender, EventArgs e)
        {
            staf.ID = -99;
            staf.CID = Convert.ToInt64(Session["cid"].ToString());
            staf.S_NAME = Txtsname.Text;
            staf.S_ADDRESS = Txtsadd.Text;
            staf.S_CITY = Txtcity.Text;
            staf.S_STATE = Txtstate.Text;
            staf.S_PINCODE = Convert.ToInt64(Txtspin.Text);
            staf.S_PHONE_NO = Convert.ToInt64(Txtsphone.Text);
            staf.S_EMAIL_ID = Txtemail.Text;
            staf.S_JOIN_DATE =Convert.ToDateTime(Txtjoindate.Text);
            staf.S_DESIGNATION = Txtdesi.Text;
            staf.SALARY = Convert.ToInt64(Txtsalery.Text);
            staf.ISDELETED = false;
            staf.SaveRecords();
            Response.Redirect("staff.aspx");
            

        }

    
        protected void Button3_Click(object sender, EventArgs e)
        {

        }

        protected void btnEdit_Command(object sender, CommandEventArgs e)
        {
            DataTable dt =staf.GetRecords(Convert.ToInt64(e.CommandArgument.ToString()),-99,"","","","",-99,-99,"", Convert.ToDateTime("1/1/1800"),"",-99, false, " and ");
            txtid.Text= dt.Rows[0]["ID"].ToString();
            Txtcid.Text =dt.Rows[0]["CID"].ToString();
            Txtsname.Text=dt.Rows[0]["S_NAME"].ToString();
            Txtsadd.Text = dt.Rows[0]["S_ADDRESS"].ToString();
            Txtcity.Text = dt.Rows[0]["S_CITY"].ToString();
            Txtstate.Text = dt.Rows[0]["S_STATE"].ToString();
            Txtspin.Text=dt.Rows[0]["S_PINCODE"].ToString();
            Txtsphone.Text =dt.Rows[0]["S_PHONE_NO"].ToString();
            Txtemail.Text = dt.Rows[0]["S_EMAIL_ID"].ToString();
            Txtjoindate.Text =dt.Rows[0]["S_JOIN_DATE"].ToString();
            Txtdesi.Text = dt.Rows[0]["S_DESIGNATION"].ToString();
            Txtsalery.Text=dt.Rows[0]["SALARY"].ToString();
                      
       
        }

        protected void btnDelete_Command(object sender, CommandEventArgs e)
        {
            DataTable dt = staf.GetRecords(Convert.ToInt64(e.CommandArgument.ToString()), -99, "", "", "", "", -99, -99, "", Convert.ToDateTime("1/1/1800"), "", -99, false, " and ");
            staf.ID = Convert.ToInt64(dt.Rows[0]["ID"].ToString());
            staf.CID = Convert.ToInt64(dt.Rows[0]["CID"].ToString());
            staf.S_NAME = dt.Rows[0]["S_NAME"].ToString();
            staf.S_ADDRESS = dt.Rows[0]["S_ADDRESS"].ToString();
            staf.S_CITY = dt.Rows[0]["S_CITY"].ToString();
            staf.S_STATE = dt.Rows[0]["S_STATE"].ToString();
            staf.S_PINCODE=Convert.ToInt64(dt.Rows[0]["S_PINCODE"].ToString());
            staf.S_PHONE_NO = Convert.ToInt64(dt.Rows[0]["S_PHONE_NO"].ToString());
            staf.S_EMAIL_ID = dt.Rows[0]["S_EMAIL_ID"].ToString();
            staf.S_JOIN_DATE = Convert.ToDateTime(dt.Rows[0]["S_JOIN_DATE"].ToString());
            staf.S_DESIGNATION = dt.Rows[0]["S_DESIGNATION"].ToString();
            staf.SALARY = Convert.ToInt64(dt.Rows[0]["SALARY"].ToString());
            staf.ISDELETED = true;
            staf.SaveRecords();
            Response.Redirect("staff.aspx");
        }

       

        protected void GridView1_RowEditing(object sender, GridViewEditEventArgs e)
        {

        }

        protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e)
        {

        }

        protected void btupdate_Click(object sender, EventArgs e)
        {

            staf.ID = -99;
            staf.CID = Convert.ToInt64(Session["cid"].ToString());
            staf.S_NAME = Txtsname.Text;
            staf.S_ADDRESS = Txtsadd.Text;
            staf.S_CITY = Txtcity.Text;
            staf.S_STATE = Txtstate.Text;
            staf.S_PINCODE = Convert.ToInt64(Txtspin.Text);
            staf.S_PHONE_NO = Convert.ToInt64(Txtsphone.Text);
            staf.S_EMAIL_ID = Txtemail.Text;
            staf.S_JOIN_DATE = Convert.ToDateTime(Txtjoindate.Text);
            staf.S_DESIGNATION = Txtdesi.Text;
            staf.SALARY = Convert.ToInt64(Txtsalery.Text);
            staf.ISDELETED = false;
            staf.SaveRecords();
            Response.Redirect("staff.aspx");
        }

        protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
        {

        }

       
        }
    }

